import UTIL from './utils'
const { formatAmountToUnits, formatInt, formatPercent } = UTIL

// 基本信息
export const baseMap = [{
    key: 'enterpriseName',
    label: '企业名称'
}, {
    key: 'legalPerson',
    label: '当前法人姓名'
}, {
    key: 'age',
    label: '法人年龄（岁）'
}, {
    key: 'stockStatus',
    label: '法人是否占股',
    formatter: val => !!val ? '是' : '否'
}, {
    key: 'stockPercent',
    label: '法人股份占比（%）',
    formatter: formatPercent
}, {
    key: 'registerDate',
    label: '成立日期'
}, {
    key: 'registerMonth',
    label: '成立时长',
    formatter: val => val !== null ? val + '个月' : '-'
}, {
    key: 'creditCode',
    label: '统一信用代码'
}, {
    key: 'industry',
    label: '行业分类'
}, {
    key: 'loginRegisterType',
    label: '注册类型'
}, {
    key: 'registerAddress',
    label: '注册区域'
}, {
    key: 'openAccountBank',
    label: '基本户'
}, {
    key: 'bankTaxRecord',
    label: '银税互动授权记录'
}]

// 股东明细
export const stockMap = [
    { key: 'stockName', label: '股东名称', width: 200 },
    { key: 'stockType', label: '股东类型', width: 100 },
    { key: 'shouldCapi', label: '参股数额(万)', width: 100 },
    { key: 'stockPercent', label: '参股比例', formatter: formatPercent, width: 100 },
]

// 纳税信息
export const taxMap = [{
    key: 'evaluationResult',
    label: '纳税信用等级',
    formatter: val => {
        return val?.includes('具体原因') ? '-' : val || '-'
    }
}, {
    key: 'qualification',
    label: '纳税人种类'
}, {
    key: 'qualificationValidFrom',
    label: '纳税人种类生效日期',
    formatter: val => val?.slice(0, 10) || '-'
}, {
    key: 'taxRegister',
    label: '税务登记日期',
    formatter: val => val?.slice(0, 10) || '-'
}, {
    key: 'unpaidTaxStatus',
    label: '历史有无欠税记录',
    formatter: val => val === true ? '有' : '无'
}, {
    key: 'taxDelinquencyRecordCountPast12Months',
    label: '近1年欠税记录数',
    formatter: formatInt
}, {
    key: 'last12MaxZeroTaxMonths',
    label: '近1年最大连续0纳税申报月数',
    formatter: formatInt
}, {
    key: 'lateFeesStatus',
    label: '滞纳金情况',
    formatter: val => val === true ? '有' : '无'
}, {
    key: 'unpaidTaxAmount',
    label: '当前欠税金额(元)',
    formatter: formatAmountToUnits
}]

// 滞纳金情况
export const lateAmountMap = [
    { key: 'taxPeriodStart', label: '起始时间' },
    { key: 'paymentDate', label: '缴款时间' },
    { key: 'paymentAmount', label: '滞纳金金额', formatter: formatAmountToUnits },
]

// 近两年纳税信用等级
export const creditMap = [
    { key: 'evaluationYear', label: '评级年度' },
    { key: 'evaluationScore', label: '评级得分' },
    { key: 'evaluationResult', label: '评价结果' },
    { key: 'indicatorNames', label: '扣减分项', width: 400, formatter: val => val?.join('；') },
]

// 税务违法违规信息
export const illegalMap = [
    { key: 'actionName', label: '违法行为名称' },
    { key: 'infractionMeans', label: '税收违法手段' },
    { key: 'registerDate', label: '税务局登记日期' },
    { key: 'taxPeriodStart', label: '违法违章所属期起' },
    { key: 'taxPeriodEnd', label: '违法违章所属期止' },
    { key: 'processState', label: '处理状态' },
    { key: 'caseState', label: '案件状态' },
    { key: 'illegalFact', label: '违法事实' },
    { key: 'isSocialSecurityViolation', label: '是否社保违法' },
]

// 财务情况
export const financeMap = [
    {
        key: 'totalAssets', label: '资产合计', formatter: formatAmountToUnits
    },
    { key: 'totalLiabilities', label: '负债合计', formatter: formatAmountToUnits },
    { key: 'ownerEquity', label: '所有者权益合计', formatter: formatAmountToUnits },
    { key: 'liabilitiesOwnerEquity', label: '负债和所有者权益总计', formatter: formatAmountToUnits },
    { key: 'businessIncome', label: '营业收入', formatter: formatAmountToUnits },
    { key: 'businessProfit', label: '营业利润', formatter: formatAmountToUnits },
    { key: 'totalProfit', label: '利润总额', formatter: formatAmountToUnits },
    { key: 'netProfits', label: '净利润', formatter: formatAmountToUnits },
    { key: 'thisYearNetIncrease', label: '现金净增加额', formatter: formatAmountToUnits },
    { key: 'thisYearFinalBalance', label: '期末现金余额', formatter: formatAmountToUnits },
]

// 开具发票
export const billMap = [
    {
        key: 'billingRecords', label: '近45日是否有开票记录', formatter: val => val === true ? '有' : '无'
    },
    { key: 'billingDaysSum', label: '近30天开票金额', formatter: formatAmountToUnits },
    { key: 'taxVoidRateMonth12', label: '近12月作废发票数量占比', formatter: formatPercent },
    { key: 'breakMonthsSum', label: '近12个月断票月数', formatter: formatInt },
    { key: 'taxAmountGrowthRateMonth12', label: '近12个月月均开票金额同比增长率', formatter: formatPercent },
    { key: 'earliestTime', label: '最早开票时间' },
    { key: 'latestTime', label: '最晚开票时间', formatter: val => UTIL.getDateDiff(val) },
]

// 开票断票
export const billBreakMap = [
    { key: 'breakMonthsSum12', label: '近12月最长连续断票月数', formatter: formatInt },
    { key: 'taxOutputNotInvoicedMonth12', label: '近12月最大连续未开具发票间断天数（销项）', formatter: formatInt },
    { key: 'recentBillingGapdays', label: '最近开具发票间断天数', formatter: formatInt },
]

// 申报数据
export const applyMap = [
    {
        key: 'applyRecords', label: '近45日是否有申报记录', formatter: val => val === true ? '有' : '无'
    },
    { key: 'applyAmountMonths1', label: '近30天申报金额', formatter: formatAmountToUnits },
    { key: 'applySum12', label: '近12个月申报次数', formatter: formatInt },
]

// 纳税数据分析
export const ratepayingMap = [
    { key: 'unpaidTaxAmount', label: '欠税金额', formatter: formatAmountToUnits },
    { key: 'taxSaleAmount', label: '纳税销售额', formatter: formatAmountToUnits },
    { key: 'taxPaidAmount', label: '纳税实缴金额', formatter: formatAmountToUnits },
    { key: 'coiled0Months', label: '0申报月数', formatter: formatInt },
    { key: 'debtRatio', label: '负债率', formatter: formatPercent },
    { key: 'profitRatio', label: '利润率', formatter: formatPercent },
    { key: 'vatPayableAmount', label: '增值税应纳额', formatter: formatAmountToUnits },
    { key: 'taxIncomeAmount', label: '企业所得税', formatter: formatAmountToUnits },
    { key: 'taxWaiverAmount', label: '减免税额', formatter: formatAmountToUnits },
    { key: 'lateFeesNum', label: '滞纳金次数', formatter: formatInt },
    { key: 'lateFeesAmount', label: '滞纳金金额', formatter: formatAmountToUnits },
]

// 开票对比
export const billcompareMap = [
    { key: 'invoiceAmount', label: '开票金额', formatter: formatAmountToUnits },
    { key: 'invoiceGrowthRate', label: '开票环比增长率', formatter: formatPercent },
    { key: 'invoiceOverGrowthRate', label: '开票同比增长率', formatter: formatPercent },
    { key: 'invoiceCount', label: '开票张数', formatter: formatInt },
    { key: 'invoiceMonthsNum', label: '开票月数', formatter: formatInt },
    { key: 'invoiceRedCountRate', label: '红冲发票张数占比', formatter: formatPercent },
    { key: 'invoiceRedAmountRate', label: '红冲金额占比', formatter: formatPercent },
    { key: 'customerUpNum', label: '上游客户数量', formatter: formatInt },
    { key: 'customerDownNum', label: '下游客户数量', formatter: formatInt },
]

// 申报对比
export const applycompareMap = [
    { key: 'applyAmount', label: '申报金额', formatter: formatAmountToUnits },
    { key: 'applyGrowthRate', label: '申报环比增长率', formatter: formatPercent },
    { key: 'applyOverGrowthRate', label: '申报同比增长率', formatter: formatPercent },
]

// 取得发票
export const invoiceMap = [
    {
        key: 'billingRecords', label: '近45日是否有取得发票记录', formatter: val => val === true ? '有' : '无'
    },
    { key: 'billingDaysSum', label: '近30天取得发票金额', formatter: formatAmountToUnits },
    { key: 'taxVoidRateMonth12', label: '近12月作废发票数量占比', formatter: formatPercent },
    { key: 'breakMonthsSum', label: '近12个月断票月数', format: formatInt },
    { key: 'taxAmountGrowthRateMonth12', label: '近12个月月均取得发票金额同比增长率', formatter: formatPercent },
    { key: 'earliestTime', label: '最早取得发票时间' },
    { key: 'latestTime', label: '最晚取得发票时间', formatter: val => UTIL.getDateDiff(val) },
]

// 取得断票
export const invoicBreakeMap = [
    { key: 'breakMonthsSum12', label: '近12月最长连续断票月数', formatter: formatInt },
    { key: 'taxOutputNotInvoicedMonth12', label: '近12月最大连续未取得发票间断天数（销项）', formatter: formatInt },
    { key: 'recentBillingGapdays', label: '最近取得发票间断天数', formatter: formatInt },
]

// 取得对比
export const invoicecompareMap = [
    { key: 'invoiceAmount', label: '取得金额', formatter: formatAmountToUnits },
    { key: 'invoiceGrowthRate', label: '取票环比增长率', formatter: formatPercent },
    { key: 'invoiceOverGrowthRate', label: '取票同比增长率', formatter: formatPercent },
    { key: 'invoiceCount', label: '取票张数', formatter: formatInt },
    { key: 'invoiceMonthsNum', label: '取票月数', formatter: formatInt },
    { key: 'invoiceRedCountRate', label: '红冲取票张数占比', formatter: formatPercent },
    { key: 'invoiceRedAmountRate', label: '红冲金额占比', formatter: formatPercent },
    { key: 'customerUpNum', label: '上游客户数量', formatter: formatInt },
    { key: 'customerDownNum', label: '下游客户数量', formatter: formatInt },
]

// 供应商
export const companyMap = [
    { key: 'sort', label: '排名', width: 60 },
    { key: 'buySaleName', label: '供应商名称', width: 300 },
    { key: 'sumAmount', label: '采购额（元）', width: 120, formatter: formatAmountToUnits },
    { key: 'amountRate', label: '金额占比（%）', width: 120, formatter: formatPercent },
    { key: 'relatedStatus', label: '是否关联方', width: 100, formatter: val => val === true ? '是' : '否' },
]

const formatSlim = val => formatInt(val, true)
// 工商司法
export const enterpriseMap = [
    {
        key: 'enterpriseDishonestSum', label: '失信被执行条数', formatter: formatSlim
    },
    { key: 'executedPersonSum', label: '被执行条数', formatter: formatSlim },
    { key: 'courtNoticeSum', label: '法院公告条数', formatter: formatSlim },
    { key: 'enterpriseCaseSum', label: '判决文书条数', formatter: formatSlim },
    { key: 'subjectAmount', label: '总涉案金额', formatter: formatAmountToUnits },
    { key: 'changeStatus', label: '近6月是否有法人变更', formatter: val => val === true ? '是' : '否' },
]

// 工商变更
export const changeMap = [
    { key: 'name', label: '变更项目', width: 200 },
    { key: 'changeDate', label: '变更日期', width: 130 },
    { key: 'beforeContent', label: '变更前内容', width: 300 },
    { key: 'affterContent', label: '变更后内容', width: 300 },
]

// 判决文书
export const caseMap = [
    { key: 'name', label: '文书标题', width: 180 },
    { key: 'reason', label: '案由', width: 300 },
    { key: 'roleType', label: '案件身份', width: 300 },
    { key: 'judgeDate', label: '案件日期', width: 130 },
]

export default {
    baseMap,
    stockMap,
    taxMap,
    lateAmountMap,
    creditMap,
    financeMap,
    billMap,
    billBreakMap,
    applyMap,
    companyMap,
    enterpriseMap,
    caseMap,
    ratepayingMap,
    billcompareMap,
    illegalMap,
    applycompareMap,
    invoiceMap,
    invoicBreakeMap,
    invoicecompareMap,
    changeMap
}